home *** CD-ROM | disk | FTP | other *** search
- /*==============================================================================
- *
- * File: MFMEMORY.C
- *
- * Function: Memory allocation routines
- *
- * Author(s): Rick Wong (RWW)
- *
- * Copyright: (c) 1995 by Apple Computer, Inc., all rights reserved.
- *
- * Change History (most recent first):
- * Fabio Changed file name to 8 characters
- * F3L_RWW File created.
- *==============================================================================
- */
- #define MF3D_MEMORY_C
- #include "MFMEMORY.H"
- #undef MF3D_MEMORY_C
-
- #include <stdlib.h>
-
- #include "MFASSERT.H"
-
- void *
- MF3D_Malloc(
- size_t size)
- {
- #if defined(DEBUG) && DEBUG > 1
- void *tempPtr;
-
- tempPtr = malloc(size);
- printf("%d: malloc(%lx)\n", ++gMallocCount, tempPtr);
- return tempPtr;
- #else
- return malloc(size);
- #endif
- }
-
- #include <types.h>
- void *
- MF3D_Realloc(
- void * ptr,
- size_t size)
- {
- #if defined(DEBUG) && DEBUG > 1
- void *tempPtr;
-
- /* The C manual does not seem to explicitly state that
- * realloc(NULL, size) is equivalent to malloc(size).
- * So, to make sure we do not fail with some compiler somewhere,
- * we will always malloc before realloc.
- */
- MFASSERT(ptr != NULL);
- MFASSERT(size > 0);
- tempPtr = realloc(ptr, size);
- if (tempPtr != ptr)
- { if (ptr == NULL)
- ++gMallocCount;
- printf("%d: realloc(%lx to %lx)\n", gMallocCount, ptr, tempPtr);
- }
- return tempPtr;
- #else
- return realloc(ptr, size);
- #endif
- }
-
- void
- MF3D_Free(
- void * ptr)
- {
- #if defined(DEBUG) && DEBUG > 1
- free(ptr);
- if (ptr != NULL)
- { printf("%d: free(%lx)\n", --gMallocCount, ptr);
- }
- #else
- free(ptr);
- #endif
- }
-